﻿using WorkflowCore.Interface;

namespace B.S.BaseData.Read.Api.Application.CommandHander.Workflow
{
    public static class ConfigureExtensions
    {
        public static IApplicationBuilder UseWorkflow(this IApplicationBuilder app)
        {
            // 注册工作流
            var host = app.ApplicationServices.GetService<IWorkflowHost>();
            // 因为改成了Json定义流程了
            // host.RegisterWorkflow<HelloWorldWorkflow>();
            host.Start();
            var lifetime =
            app.ApplicationServices.GetService<IHostApplicationLifetime>();
            lifetime.ApplicationStopping.Register(() =>
            {
                host.Stop();
            });
            return app;
        }
    }
}
